/* ************************************************************************** *
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.
 * 
 * This file is licensed to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 * ************************************************************************** */
package org.statewalker.fsm;

/**
 * This is a strategy used to provide new states for processes. Processes (
 * {@link FsmProcess} instances) delegates to objects of this type the creation
 * of new states. State providers could be considered as an implementation of a
 * "transition table" which defines where the system should go for each state
 * when an event is occurred. Some implementation could be based on "hard coded"
 * transitions (transitions are defined directly in the code) and some could use
 * internally configurable transition maps.
 * 
 * @author kotelnikov
 */
public interface IFsmStateProvider<S, E> {

    /**
     * Returns the next state of the process.
     * 
     * @param parent the parent state
     * @param prev the previous state (could be <code>null</code>)
     * @param event the event initializing the transition from the given
     *        sub-state
     * @return the next state corresponding to the specified transition
     */
    S getNextState(S parent, S prev, E event);

    /**
     * Returns a newly created root state of the process
     * 
     * @param event the initial event
     * @return a newly created root state of the process
     */
    S getRootState(E event);
}
